package com.yellowpage.bigdata.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.yellowpage.white.common.Constants;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import com.yellowpage.bigdata.data.NspOnofflogTaVersionDay;
import com.yellowpage.bigdata.dao.NspOnofflogTaVersionDayDao;

public class NspOnofflogTaVersionDayServiceImpl extends BaseServiceImpl implements NspOnofflogTaVersionDayService {
	  private NspOnofflogTaVersionDayDao nspOnofflogTaVersionDayDao;
	
	  public void setNspOnofflogTaVersionDayDao(NspOnofflogTaVersionDayDao nspOnofflogTaVersionDayDao) {
		  this.nspOnofflogTaVersionDayDao = nspOnofflogTaVersionDayDao;
	  }
	
	
	  /* Smooth generate Method */ 
	  public NspOnofflogTaVersionDay getNspOnofflogTaVersionDay(Long id){
	      return nspOnofflogTaVersionDayDao.get(id);
	  }
	  
    public List<NspOnofflogTaVersionDay> getAllNspOnofflogTaVersionDay(){
        return nspOnofflogTaVersionDayDao.getAll();
    }
    
    public List<Map> queryNspOnofflogTaVersionDayByPage(Map queryMap, PageRender pageRender) {		
        
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.NSP_ONOFFLOG_TA_VERSION_DAY_ID , a.VERSION , a.IOS_COUNT , a.CREATE_USER , a.LOG_DATE , a.NOTE , a.CREATE_TIME , a.IMEI_DAY_COUNT , a.IMEI_NEW_COUNT , a.ANDROID_COUNT , a.IMEI_ALL_COUNT    FROM NSP_ONOFFLOG_TA_VERSION_DAY a WHERE 1=1 ")

							    			.addCondition(" and VERSION = :query_appVersion ")
											.addCondition(" and a.LOG_DATE >= :logDate ")
											.addCondition(" and a.LOG_DATE <= :query_logDate_end ")


				;


		List<Map> resultList;

		//当pageRender存在的时候，跳转
		if (pageRender != null)
		{ resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);}

		//否则取全量
		else

		{ resultList = sqlAssistant.query(
				baseDao.getConnection(), queryMap);}


		return resultList;
	}
    
    
    public void saveNspOnofflogTaVersionDay(NspOnofflogTaVersionDay nspOnofflogTaVersionDay){
        nspOnofflogTaVersionDayDao.save(nspOnofflogTaVersionDay);
    }
    
	  public void updateNspOnofflogTaVersionDay(NspOnofflogTaVersionDay nspOnofflogTaVersionDay){
	      nspOnofflogTaVersionDayDao.update(nspOnofflogTaVersionDay);
	  }
	  
	  public void delete(List deleteList){
	      nspOnofflogTaVersionDayDao.remove(deleteList);
	  }
	  
	  
	 
	
}	